package com.zkthink.exception;

import com.zkthink.exception.code.BaseExceptionCode;

/**
 * @Author Xiaoyan
 * @create 2021/12/22 17:58
 */
public class TencentPicException extends BaseUncheckedException {
    private static final long serialVersionUID = -3843912314424124217L;

    public TencentPicException(String message) {
        super(-1, message);
    }

    public TencentPicException(int code, String message) {
        super(code, message);
    }

    public TencentPicException(int code, String message, Object... args) {
        super(code, message, args);
    }

    /**
     * 实例化异常
     *
     * @param code    自定义异常编码
     * @param message 自定义异常消息
     * @param args    已定义异常参数
     * @return
     */
    public static TencentPicException wrap(int code, String message, Object... args) {
        return new TencentPicException(code, message, args);
    }

    public static TencentPicException wrap(String message, Object... args) {
        return new TencentPicException(-1, message, args);
    }

    public static TencentPicException validFail(String message, Object... args) {
        return new TencentPicException(-9, message, args);
    }

    public static TencentPicException wrap(BaseExceptionCode ex) {
        return new TencentPicException(ex.getCode(), ex.getMsg());
    }

    @Override
    public String toString() {
        return "TencentPicException [message=" + message + ", code=" + code + "]";
    }
}
